package com.example.translateappjava.Service.MedicalAtlas;

import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class MedicalAtlasImplication implements MedicalAtlasInterface.MedicalAtlasGet {
    private static final String API_URL = "https://api.a20safe.com/api.php?api=60";
    private static final String AUTH_KEY = "eac190d8b34c0e57443b77b44deed248";
    @Override
    public String getMedicalAtlasResult(String message) {
        String url = API_URL+"&"+"key"+"="+ AUTH_KEY+"&"+"keyword"+"="+message;
        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder()
                .url(url)
                .build();
        try (Response response = okHttpClient.newCall(request).execute()){
            System.out.println("Response Code: "+ response.code());
            System.out.println(response.body().string());
        }
        catch (IOException e){
            e.printStackTrace();
        }
        return request.toString();
    }
}
